<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<% response.setContentType("text/html; charset=UTF-8");%>
<% request.setCharacterEncoding("utf-8");%>
<%@page import="controller.ModuleExamController, dto.*" %>
<%@ page import="java.sql.*" %>

<%
    String tenloai = request.getParameter("tenloai");
    String thoigian = request.getParameter("thoigian");
    String socaude = request.getParameter("socaude");
    String socautb = request.getParameter("socautb");
    String socaukho = request.getParameter("socaukho");
    if (tenloai != null && thoigian != null && socaude != null && socautb != null && socaukho != null) {
        ModuleExamController ctrl = new ModuleExamController();
        try {
            int max = ctrl.getLoaiDeThiLonNhat();
            String maLDT = Integer.toString(max + 1);
            if (ctrl.themLoaiDeThi(maLDT, tenloai, thoigian, socaude, socautb, socaukho) == true) {
                out.println("Phát sinh thành công. Mã loại đề thi : " + maLDT); // phát sinh thành công
                response.sendRedirect("../thi_dethi_phatsinh.jsp?maldt=" + maLDT);
            }
        } catch (Exception e) {
            out.println(e.getMessage());
        }
    }
%>